package com.ruoyi.web.controller.teaching;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.teaching.domain.PlatformNNotes;
import com.ruoyi.teaching.service.PlatformNNotesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王旭
 * @since 2024-07-02
 */
@RestController
@RequestMapping("/platform/notes")
@Api(tags = "platform-笔记管理")
@Validated
public class  PlatformNNotesController {
    @Autowired
    private PlatformNNotesService platformNNotesService;

    /**
     * 查询某一课时下自己的笔记
     */
//    @PreAuthorize("@ss.hasPermi('platform:notes:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询某一课时下自己的笔记",notes = "查询某一课时下自己的笔记")
    public AjaxResult list(Integer partId, Integer courseId, Integer outlineId)
    {
        return platformNNotesService.selectPlatformNNotesList(partId,courseId,outlineId);
    }

    /**
     * 查询自己所有笔记
     */
//    @PreAuthorize("@ss.hasPermi('platform:notes:listAll')")
    @GetMapping("/listAll")
    @ApiOperation(value = "查询自己所有笔记",notes = "查询自己所有笔记")
    public AjaxResult listAll()
    {
        return platformNNotesService.selectPlatformNNotesListAll();
    }

    /**
     * 查询某一项目下自己的所有笔记
     */
    @GetMapping("/listByProjectId")
    @ApiOperation(value = "查询某一项目下自己的所有笔记",notes = "查询某一项目下自己的所有笔记")
    public AjaxResult listByProjectId(Integer pageNum, Integer pageSize, Integer projectId){
        return platformNNotesService.selectPlatformNNotesByProjectId(pageNum,pageSize,projectId);
    }

    /**
     * 获取笔记详细信息
     */
//    @PreAuthorize("@ss.hasPermi('platform:notes:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取笔记详细信息",notes = "获取笔记详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return platformNNotesService.selectPlatformNNotesById(id);
    }

    /**
     * 新增笔记
     */
//    @PreAuthorize("@ss.hasPermi('platform:notes:add')")
    @Log(title = "【新增笔记】", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增笔记",notes = "新增笔记")
    @PostMapping
    public AjaxResult add(@Valid @RequestBody PlatformNNotes platformNNotes)
    {
        return platformNNotesService.insertPlatformNNotes(platformNNotes);
    }

    /**
     * 修改笔记
     */
//    @PreAuthorize("@ss.hasPermi('platform:notes:edit')")
    @Log(title = "【修改笔记】", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改笔记",notes = "修改笔记")
    public AjaxResult edit(@RequestBody PlatformNNotes platformNNotes)
    {
        return platformNNotesService.updatePlatformNNotes(platformNNotes);
    }

    /**
     * 删除笔记
     */
//    @PreAuthorize("@ss.hasPermi('platform:notes:remove')")
    @Log(title = "【删除笔记】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除笔记",notes = "删除笔记")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return platformNNotesService.deletePlatformNNotesByIds(ids);
    }
}

